package com.geek.service.impl;

import com.geek.mapper.MarketUserMapper;
import com.geek.model.MarketUser;
import com.geek.model.MarketUserExample;
import com.geek.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 小豪
 * @version 1.0
 * @description
 * @date 2024-06-13 20:28
 */
@Service
public class AuthServiceImpl implements AuthService {

    @Autowired
    private MarketUserMapper userMapper;

    /**
     * 根据用户名查询用户是否存在
     * @param username 用户名
     */
    @Override
    public MarketUser findByUsername(String username) {
        MarketUserExample userExample = new MarketUserExample();
        userExample.createCriteria().andDeletedEqualTo(false).andUsernameEqualTo(username);
        List<MarketUser> marketUsers = userMapper.selectByExample(userExample);
        return marketUsers != null && marketUsers.size() == 1 ? marketUsers.get(0) : null;
    }
}
